<%layout("/common/layout.html",{title:"用户信息"}){ %>
<form class="form-inline definewidth m20" action="/userinfosearch?" method="get">
    用户名称：
    <input type="text" name="username" id="username"class="abc input-default" placeholder="" value="">&nbsp;&nbsp;
    <button type="submit" class="btn btn-primary">查询</button>&nbsp;&nbsp; <button type="button" class="btn btn-success" id="addnew">新增用户</button>
</form>

<table class="table table-bordered table-hover definewidth m10">
    <thead>
    <tr>
        <th>用户id</th>
        <th>用户名称</th>
        <th>真实密码</th>
        <th>操作</th>
    </tr>
    </thead>
    <% for (item in userlist){%>
    <tr>
        <td>${item.userID}</td>
        <td>${item.userName}</td>
        <td>${item.userPwd}</td>
        <td>
            <a href="/useredit/${item.userID}">编辑</a> &nbsp;&nbsp; <a href="javascript:;" onclick="btn_delete('${item.userID}')">删除</a>
        </td>
    </tr>
    <%}%>
</table>
<%}%>

<script>
    $(function () {
        $('#addnew').click(function(){
            window.location.href="/useradd";
        });
    });

    function btn_delete(id)
    {
        if(confirm("确定要删除吗？"))
        {
            $.post("/userdelete",{userid:id},function(serverData){
                if(serverData.status==0){
                    alert('删除成功！');
                    window.location = '/userinfo';
                }else  {
                    alert(serverData.msg);
                }
            });
        }
    }
</script>